(()=>{"use strict";const e=window.React,t=window.wp.element,n=window.wc.wcBlocksRegistry,s=window.wp.htmlEntities,c=window.wc.wcSettings,o="mercadopago_blocks_update_cart",a=({title:t,description:n,linkText:s,linkSrc:c})=>(0,e.createElement)("div",{className:"mp-checkout-pro-test-mode"},(0,e.createElement)("test-mode",{title:t,description:n,"link-text":s,"link-src":c})),i=({title:t,subtitle:n,alt:s,linkSrc:c})=>(0,e.createElement)("pix-template",{title:t,subtitle:n,alt:s,src:c}),r=({description:t,linkText:n,linkSrc:s,checkoutClass:c="pro"})=>(0,e.createElement)("div",{className:`mp-checkout-${c}-terms-and-conditions`},(0,e.createElement)("terms-and-conditions",{description:t,"link-text":n,"link-src":s})),l=(e,t,n)=>{const s={name:e,message:t,target:n,plugin:{version:wc_mercadopago_custom_checkout_params.plugin_version},platform:{name:"woocommerce",uri:window.location.href,version:wc_mercadopago_custom_checkout_params.platform_version,location:`${wc_mercadopago_custom_checkout_params.location}_${wc_mercadopago_custom_checkout_params.theme}`}};navigator.sendBeacon("https://api.mercadopago.com/v1/plugins/melidata/errors",JSON.stringify(s))};var m;const p="mp_checkout_blocks",d="woo-mercado-pago-pix",_=(0,c.getSetting)("woo-mercado-pago-pix_data",{}),u=(0,s.decodeEntities)(_.title)||"Checkout Pix",k=n=>{(e=>{const{extensionCartUpdate:n}=wc.blocksCheckout,{eventRegistration:s,emitResponse:c}=e,{onPaymentSetup:a,onCheckoutSuccess:i,onCheckoutFail:r}=s;(0,t.useEffect)((()=>{((e,t)=>{e({namespace:o,data:{action:"add",gateway:t}})})(n,d);const e=a((()=>({type:c.responseTypes.SUCCESS})));return()=>(((e,t)=>{e({namespace:o,data:{action:"remove",gateway:t}})})(n,d),e())}),[a]),(0,t.useEffect)((()=>{const e=i((async e=>{e.processingResponse.message=d;const t=e.processingResponse;return l("MP_PIX_BLOCKS_SUCCESS",t.paymentStatus,p),{type:c.responseTypes.SUCCESS}}));return()=>e()}),[i]),(0,t.useEffect)((()=>{const e=r((e=>{const t=e.processingResponse;return l("MP_PIX_BLOCKS_ERROR",t.paymentStatus,p),{type:c.responseTypes.FAIL,messageContext:c.noticeContexts.PAYMENTS,message:t.paymentDetails.message}}));return()=>e()}),[r])})(n);const{test_mode_title:s,test_mode_description:c,pix_template_title:m,pix_template_subtitle:u,pix_template_src:k,pix_template_alt:g,terms_and_conditions_description:w,terms_and_conditions_link_text:E,terms_and_conditions_link_src:S,test_mode:h}=_.params;return(0,e.createElement)("div",{className:"mp-checkout-container"},(0,e.createElement)("div",{className:"mp-checkout-pix-container"},(0,e.createElement)("div",{className:"mp-checkout-pix-content"},h?(0,e.createElement)(a,{title:s,description:c}):null,(0,e.createElement)(i,{title:m,subtitle:u,alt:g,linkSrc:k}))),(0,e.createElement)(r,{description:w,linkText:E,linkSrc:S,checkoutClass:"pix"}))},g={name:d,label:(0,e.createElement)((t=>{const{PaymentMethodLabel:n}=t.components,c=(0,s.decodeEntities)(_?.params?.fee_title||""),o=`${u} ${c}`;return(0,e.createElement)(n,{text:o})}),null),content:(0,e.createElement)(k,null),edit:(0,e.createElement)(k,null),canMakePayment:()=>!0,ariaLabel:u,supports:{features:null!==(m=_?.supports)&&void 0!==m?m:[]}};(0,n.registerPaymentMethod)(g)})();